// Cmd.h : 
//

#pragma once

class Cmd{
private:
	CString m_strCmd;
	BOOL m_bValid;
	CString m_strCmdRestult;	//result by RunWithPipe()

private:
	BOOL CheckCmd();	//check if the cmd is valid, it may change

public:
	Cmd(const CString &strCmd = _T(""));
	~Cmd();

	BOOL SetCmd(const CString &strCmd);
	CString GetCmd() const;

	BOOL IsValid() {return m_bValid;}

	BOOL Run(BOOL bNonBlock = TRUE, DWORD dwFlags = STARTF_USESHOWWINDOW, WORD wShowWindow = SW_HIDE, HANDLE hStdOutput = NULL, HANDLE hStdError = NULL) const;
	BOOL Run(const CString &outputFileName) const;	//put the result to outputfile
	BOOL RunWithPipe(CString &strResult) const;	//put the result to strRestult
	BOOL RunWithPipe();	//put the result to private member m_strCmdRestult
	CString GetCmdResult()const {return m_strCmdRestult;}

};

